<template>
	<view class="count p-30">
		<view class="top ">
			<view class="initJi">
				当前积分
			</view>
			<view class="num">
				{{total_score}}
			</view>
		</view>
		<view class="body">
			<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="onreachBottom">
				<view v-for="(item,index) in list" :key="index" class="bodItem f f-a-c f-j-b">
					<view class="lefName">
						<view class="name">
							{{item.from==1?'购物返现增加':item.from==2?'购物抵扣减少':'订单取消退还'}}
						</view>
						<view class="time">
							{{$u.timeFormat(item.create_time, 'yyyy-mm-dd')}}
						</view>
					</view>
					<view class="jiaPrice">
						{{item.score}}
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				list: [],
				total: 0,
				total_score: 0
			}
		},
		onShow() {
			this.page = 1
			this.list = []
			this.initList()
		},
		methods: {
			// 这个是列表
			async initList() {
				let n = await this.$api.mySorter({
					page: this.page
				})
				this.total = n.data.scores.total
				this.total_score = n.data.total_score
				this.list = [...this.list, ...n.data.scores.rows]
			},
			onreachBottom() {
				if (this.list.length < this.total) {
					this.page++
					this.initList()
				}
				console.log('55555555555');
			}
		}
	}
</script>

<style lang="scss" scoped>
	.body {
		height: calc(100vh - 300rpx);
		width: 100%;
		// background-color: pink;
		margin-top: 40rpx;

		.bodItem {
			margin-top: 25rpx;
			padding-bottom: 25rpx;
			border-bottom: 2rpx solid #f1f1f1;

			.jiaPrice {
				font-size: 32rpx;
				font-family: HarmonyOS Sans, HarmonyOS Sans-700;
				font-weight: 700;
				text-align: LEFT;
				color: #2f2319;
			}

			.lefName {
				.name {
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC-400;
					font-weight: 400;
					text-align: LEFT;
					color: #2f2319;
					margin-bottom: 10rpx;
				}

				.time {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC-400;
					font-weight: 400;
					text-align: LEFT;
					color: #ada6a0;
				}
			}
		}
	}

	.top {
		width: 100%;
		height: 196rpx;
		background: #f4efeb;
		border-radius: 32rpx;
		padding: 40rpx 50rpx;

		.initJi {
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC-400;
			font-weight: 400;
			text-align: LEFT;
			color: #ada6a0;
		}

		.num {
			font-size: 64rpx;
			font-family: HarmonyOS Sans, HarmonyOS Sans-700;
			font-weight: 700;
			text-align: left;
			color: #2f2319;
		}
	}

	.count {
		height: 100vh;
		width: 100%;
		background-color: #fffefc;
	}
</style>